using System.Collections.Generic;

namespace CleanCode
{
   // p. 18
   namespace IntentionRevealingNames
   {
      public class TheWtfWay
      {
         private readonly List<int[]> theList = new List<int[]>();

         public List<int[]> GetThem()
         {
            var list1 = new List<int[]>();
            foreach (var x in theList)
            {
               if (x[0] == 4)
                  list1.Add(x);
            }
            return list1;
         }
      }

      public class TheCleanCodeWay
      {
         private const int STATUS_VALUE = 0;
         private const int FLAGGED = 4;
         private readonly List<int[]> gameBoard = new List<int[]>();

         public List<int[]> GetFlaggedCells()
         {
            var flaggedCells = new List<int[]>();
            foreach (var cell in gameBoard)
            {
               if (cell[STATUS_VALUE] == FLAGGED)
                  flaggedCells.Add(cell);
            }
            return flaggedCells;
         }
      }

      public class TheEvenCleanerWay
      {
         private readonly List<Cell> gameBoard = new List<Cell>();

         public List<Cell> GetFlaggedCells()
         {
            var flaggedCells = new List<Cell>();
            foreach (var cell in gameBoard)
            {
               if (cell.IsFlagged)
                  flaggedCells.Add(cell);
            }
            return flaggedCells;
         }

         public class Cell
         {
            public bool IsFlagged
            {
               get { return true; }
            }
         }
      }
   }
}